var thisObject;
var thispage;
var btn_tow_status;
var DetailPage = Objs("view.components.DetailPage",
	UiComponent,
{   
	allInfo:null,
	vehicleInfo:null,
	customerInfo:null,
	vehicleLocation:null,
	commentInfo:null,
	priceInfo:null,
	cancelInfo:null,
	saveInfo:null,
	 allView:null,
	vehicleView:null,
	contactView:null,
	locationView:null,
	make:null,
	btnTowStatusNew:null,
	btnTowStatusScheduled:null,
        btnTowStatusPickeUp:null,
	btnTowStatusDelivered:null,
        btnTowStatusUnabletoContact:null,
        btnTowStatusCancelled:null,
        watchlist:null,
        share:null,
     
	
	initialize: function()
	{ 
		DetailPage.$super.initialize.call( this );
		thisObject = this;
		thispage=this;
		
		thisObject.initializeChildren();
		thisObject.bindListeners();
               
	},
	

    initializeChildren: function()
    {   
		this.allInfo = jQuery("#ainfo-li");
		this.watchlist = jQuery("#watchlist");
		this.share = jQuery("#share");
                
		this.vehicleInfo = jQuery("#vinfo-li");
		this.customerInfo = jQuery("#cinfo-li");
		this.vehicleLocation = jQuery("#vlinfo-li");
		this.commentInfo = jQuery("#ctinfo-li");
		this.priceInfo = jQuery("#pinfo-li");
		
		this.cancelInfo = jQuery("#cancel-info-btn");
		this.saveInfo = jQuery("#save-info-btn");
		
		this.allView = jQuery("#all-view-details");
		this.vehicleView = jQuery("#vehicle-view-details");
		this.contactView = jQuery("#contact-view-details");
		this.locationView = jQuery("#location-view-details");
		
		this.btnTowStatusNew = jQuery("#btn_towstatus_new");
		this.btnTowStatusScheduled = jQuery("#btn_towstatus_scheduled");
		this.btnTowStatusPickeUp = jQuery("#btn_towstatus_pickedup");
		this.btnTowStatusDelivered = jQuery("#btn_towstatus_delivered");
		this.btnTowStatusUnabletoContact = jQuery("#btn_towstatus_unabletocontact");
		this.btnTowStatusCancelled = jQuery("#btn_towstatus_cancelled");
		this.make = jQuery("#make");
           
            
               
    },

	bindListeners: function()
	{  
		var namespace = ".DetailPage";
               
		this.allInfo.on( "click"+namespace, jQuery.proxy( this, "allInfo_clickHandler" ) );
		this.vehicleInfo.on( "click"+namespace, jQuery.proxy( this, "vehicleInfo_clickHandler" ) );
		this.customerInfo.on( "click"+namespace, jQuery.proxy( this, "customerInfo_clickHandler" ) );
		this.vehicleLocation.on( "click"+namespace, jQuery.proxy( this, "vehicleLocation_clickHandler" ) );
		this.commentInfo.on( "click"+namespace, jQuery.proxy( this, "commentInfo_clickHandler" ) );
		this.priceInfo.on( "click"+namespace, jQuery.proxy( this, "priceInfo_clickHandler" ) );
		this.cancelInfo.on( "click"+namespace, jQuery.proxy( this, "cancelInfo_clickHandler" ) );
		this.saveInfo.on( "click"+namespace, jQuery.proxy( this, "saveInfo_clickHandler" ) );
		
		this.allView.on( "click"+namespace, jQuery.proxy( this, "allView_clickHandler" ) );
		this.vehicleView.on( "click"+namespace, jQuery.proxy( this, "vehicleView_clickHandler" ) );
		this.contactView.on( "click"+namespace, jQuery.proxy( this, "contactView_clickHandler" ) );
		this.locationView.on( "click"+namespace, jQuery.proxy( this, "locationView_clickHandler" ) );
		
		this.btnTowStatusNew.on( "click"+namespace, jQuery.proxy( this, "btnTowStatusNew_clickHandler" ) );
		this.btnTowStatusScheduled.on( "click"+namespace, jQuery.proxy( this, "btnTowStatusScheduled_clickHandler" ) );
		this.btnTowStatusPickeUp.on( "click"+namespace, jQuery.proxy( this, "btnTowStatusPickedUp_clickHandler" ) );
		this.btnTowStatusDelivered.on( "click"+namespace, jQuery.proxy( this, "btnTowStatusDelivered_clickHandler" ) );
		this.btnTowStatusUnabletoContact.on( "click"+namespace, jQuery.proxy( this, "btnTowStatusUnabletoContact_clickHandler" ) );
		this.btnTowStatusCancelled.on( "click"+namespace, jQuery.proxy( this, "btnTowStatusCancelled_clickHandler" ) );
		this.watchlist.on( "click"+namespace, jQuery.proxy( this, "watchlist_clickHandler" ) );
		this.share.on( "click"+namespace, jQuery.proxy( this, "share_clickHandler" ) );

		this.make.on( "click"+namespace, jQuery.proxy( this, "make_change" ) );
                  
               
           
	},
       watchlist_clickHandler:function()
	{
		this.dispatchEvent(DetailPage.WATCHLIST_START );
	},	     
	share_clickHandler:function()
	{

		this.dispatchEvent(DetailPage.SHARE_START );
	},	   
        btnTowStatusNew_clickHandler:function()
        { btn_tow_status=1;
            
                
               bootbox.confirm("Are you sure you want yo change the status?", "Cancel", "Ok", function(result) {
			 if(result==true)
			 {
			 	 thispage.dispatchEvent(DetailPage.SET_TOW_STATUS );
			 }
			 });
        },
        btnTowStatusScheduled_clickHandler:function()
        {
            btn_tow_status=2;
             bootbox.confirm("Are you sure you want yo change the status?", "Cancel", "Ok", function(result) {
			 if(result==true)
			 {
			 	 thispage.dispatchEvent(DetailPage.SET_TOW_STATUS );
			 }
			 });
        },
         btnTowStatusPickedUp_clickHandler:function()
        {
            btn_tow_status=5;
             bootbox.confirm("Are you sure you want yo change the status?", "Cancel", "Ok", function(result) {
			 if(result==true)
			 {
			 	 thispage.dispatchEvent(DetailPage.SET_TOW_STATUS );
			 }
			 });
        },
        btnTowStatusDelivered_clickHandler:function()
        { btn_tow_status=3;
            bootbox.confirm("Are you sure you want yo change the status?", "Cancel", "Ok", function(result) {
			 if(result==true)
			 {
			 	 thispage.dispatchEvent(DetailPage.SET_TOW_STATUS );
			 }
			 });
        },
         btnTowStatusUnabletoContact_clickHandler:function()
        {
            btn_tow_status=6;
             bootbox.confirm("Are you sure you want yo change the status?", "Cancel", "Ok", function(result) {
			 if(result==true)
			 {
			 	 thispage.dispatchEvent(DetailPage.SET_TOW_STATUS );
			 }
			 });
        },
         btnTowStatusCancelled_clickHandler:function()
        {
            btn_tow_status=7;
             bootbox.confirm("Are you sure you want yo change the status?", "Cancel", "Ok", function(result) {
			 if(result==true)
			 {
			 	 thispage.dispatchEvent(DetailPage.SET_TOW_STATUS );
			 }
			 });
        },
        
        allView_clickHandler:function()
        {
            $('li').removeClass('active').addClass('inactive');
            $('#all-view-details').removeClass('inactive').addClass('active');  
            
             $('#div-vehicleView').show();
               $('#div-contactView').show();
                $('#div-locationView').show();
                 $('#div-images').show();
               
        },
        vehicleView_clickHandler:function()
        {
            $('li').removeClass('active').addClass('inactive');
            $('#vehicle-view-details').removeClass('inactive').addClass('active');  
            $('#div-vehicleView').show();
            $('#div-contactView').hide();
            $('#div-locationView').hide();
            $('#div-images').hide();
        },
        contactView_clickHandler:function()
        { 
            $('li').removeClass('active').addClass('inactive');
            $('#contact-view-details').removeClass('inactive').addClass('active'); 
             $('#div-vehicleView').hide();
            $('#div-contactView').show();
            $('#div-locationView').hide();
             $('#div-images').hide();
        },
        locationView_clickHandler:function()
        {
            $('li').removeClass('active').addClass('inactive');
            $('#location-view-details').removeClass('inactive').addClass('active');   
             $('#div-vehicleView').hide();
            $('#div-contactView').hide();
            $('#div-locationView').show();
             $('#div-images').hide();
        },
        
	allInfo_clickHandler: function()
	{    
		 $('li').removeClass('active').addClass('inactive');
		 $('#ainfo-li').removeClass('inactive').addClass('active');  
	   
		
		 this.dispatchEvent( 'loadAllInfo' );	
	},
	saveInfo_clickHandler: function()
	{ 
        
	    this.dispatchEvent( DetailPage.SAVE_INFO );
            
	},
	cancelInfo_clickHandler: function()
	{ 
	   	this.dispatchEvent( DetailPage.CANCEL_INFO );
	},	
	vehicleInfo_clickHandler: function()
	{ 
	  
            $('li').removeClass('active').addClass('inactive');
            $('#vinfo-li').removeClass('inactive').addClass('active');       
            this.dispatchEvent( DetailPage.LOAD_VEHICLE_INFO );
        },   
	customerInfo_clickHandler: function()
	{ 
               $('li').removeClass('active').addClass('inactive');
            $('#cinfo-li').removeClass('inactive').addClass('active');       
	   this.dispatchEvent( DetailPage.LOAD_CUSTOMER_INFO );
	},
	vehicleLocation_clickHandler: function()
	{ 
              $('li').removeClass('active').addClass('inactive');
            $('#vlinfo-li').removeClass('inactive').addClass('active');       
		this.dispatchEvent( DetailPage.LOAD_VLOCATION_INFO );
	},
	commentInfo_clickHandler: function()
	{ 
             $('li').removeClass('active').addClass('inactive');
            $('#ctinfo-li').removeClass('inactive').addClass('active');
	  	this.dispatchEvent( DetailPage.LOAD_COMENT_INFO );
	},
	priceInfo_clickHandler: function()
	{ 
		this.dispatchEvent( DetailPage.LOAD_PRICEINFO );		
	},
	make_change:function()
	{
	
	this.dispatchEvent( DetailPage.MAKE_CHANGE );
	}

});

DetailPage.LOAD_ALL_INFO ="loadAllInfo";
DetailPage.LOAD_VEHICLE_INFO ="loadVehicleInfo";
DetailPage.LOAD_CUSTOMER_INFO ="loadCustomerInfo";
DetailPage.LOAD_VLOCATION_INFO ="loadVehicleLocationInfo";
DetailPage.LOAD_COMENT_INFO ="loadCommentInfo";
DetailPage.LOAD_PRICEINFO ="loadPriceInfo";
DetailPage.SAVE_INFO ="saveInfo";
DetailPage.CANCEL_INFO ="canbcelInfo";
DetailPage.MAKE_CHANGE ="makechange"
DetailPage.SET_TOW_STATUS ="setTowStatus";
DetailPage.WATCHLIST_START ="watchstart";
DetailPage.SHARE_START ="watchstart";